<?php
namespace Admin\Controller;

use Think\Controller;

class IndexController extends CommonController
{
    public function index()
    {
        $total_space = round((@disk_total_space(".") / (1024 * 1024)));
        $free_space = round((@disk_free_space(".") / (1024 * 1024)));
        $already_used = round($total_space - $free_space);
        $already_used_percent = round(($total_space - $free_space) / $total_space * 100);

        $server_info = array(
            'os' => PHP_OS,
            'server_software' => $_SERVER["SERVER_SOFTWARE"],
            'php' => php_sapi_name(),
            'mysql' => $this->get_mysql_version(),
            'version' => "1.0&nbsp;&nbsp;&nbsp; [<a href='http://www.canon4ever.com' target='_blank'>访问官网</a>]",
            'upload' => ini_get('upload_max_filesize'),
            'total_space' => $total_space,
            'free_space' => $free_space,
            'already_used' => $already_used,
            'already_used_percent' => $already_used_percent,
            'core' => THINK_VERSION,
        );
        //dump($server_info);
        $user_info = M('Systeminfo')->find(1);
        //dump($user_info);
        $this->assign('user_info',$user_info);
        $this->assign('server_info',$server_info);
        $this->display();
    }

    private function get_mysql_version()
    {
        $version = M()->query("select version() as ver");
        return $version[0]['ver'];
    }
}